/*
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2014
 *
 * fileName:  ResultSetImpl.java
 * author:  lei
 * Company:  Cloudland Studio
 * Createdate:  2013-9-19 下午9:33:04
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2013-9-19          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.search.handler.support;

import java.util.Date;

import org.apache.lucene.document.Document;
import org.cloudland.search.handler.ResultSet;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 {@link java.lang.Object#toString()}, 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  ResultSetImpl
 * @author  lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class ResultSetImpl implements ResultSet {

	/**
	 * id 文档编号
	 */
	private Integer id;
	
	/**
	 * score 文档评分
	 */
	private float score = 0.0F;
	
	/**
	 * document 文档内容
	 */
	private Document document;
	
	public ResultSetImpl(int id, float score, Document doc) {
		this.id = id;
		this.score = score;
		this.document = doc;
	}
	
	/**
	 * @param name
	 * @return
	 */
	public String getText(String name) {
		return document.get(name);
	}
	
	/**
	 * @param name
	 * @return
	 */
	public Float getDecimal(String name) {
		String value = document.get(name);
		return Float.parseFloat(value);
	}

	/**
	 * @param name
	 * @return
	 */
	public Date getDate(String name) {
		String value = document.get(name);
		Long lo = Long.parseLong(value);
		return new Date(lo);
	}
	
	public Float score() {
		return this.score;
	}
	
	public Integer getDocId() {
		return this.id;
	}

}
